package com.eos.control.action.customer;

import com.eos.business.service.SysProductBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.ProductBrand;
import com.eos.orm.mybatis.model.SysUser;

public class DeleteBrandAction extends AbstractBaseAction {
	private static final long serialVersionUID = 1396006354865295047L;
	private Integer brandId;

	public void setBrandId(Integer brandId) {
		this.brandId = brandId;
	}

	@Override
	public String execute() {
		try {
			if(brandId == null || brandId.longValue() <=0){
				statusCode = "300";
				message = "参数错误,删除失败!";
			}else{
				SysProductBusinessService spbs = new SysProductBusinessService();
				SysUser user = (SysUser) getSession().getAttribute("SysUser");
				ProductBrand brand = new ProductBrand();
				brand.setId(brandId);
				brand.setDealFlag(ConstantTool.DEAL_FLAG_FAIL);
				brand.setUpdateUserId(user.getId() +"");
				brand.setModifyTime(ObjectUtils.formatDate(null, "yyyy-MM-dd HH:mm:ss"));
				String exeStatus = spbs.updateProductBrandSelective(brand);
				if("SUCCESS".equals(exeStatus)){
					statusCode = "200";
					message = "删除品牌信息成功!";
				}else{
					statusCode = "300";
					message = "系统繁忙, 删除品牌信息失败!";
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常, 删除品牌信息失败!";
		}
		return SUCCESS;
	}
}
